package service.impl;

import java.util.List;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import pojo.User;
import service.UserManager;

public class UserManagerImpl implements UserManager{
	
	private UserDao dao;
	
	

	public UserManagerImpl() {
		super();
		dao = new UserDaoImpl();
	}

	@Override
	public int addUser(User u) {
		if(u == null) return 0;
		
		User user = dao.loadUserByName(u.getName());
		
		if(user != null) return 0;
		
		
		return dao.addUser(u);
	}

	@Override
	public int deleteUser(String id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateUser(User u) {
		if(u == null) return 0;
		
		return dao.updateUser(u);
	}

	@Override
	public User loadUserByName(String name) {
		// TODO Auto-generated method stub
		return dao.loadUserByName(name);
	}

	@Override
	public User loadUserById(String id) {
		// TODO Auto-generated method stub
		return dao.loadUserById(id);
	}

	@Override
	public List<User> findAllUsers() {
		// TODO Auto-generated method stub
		return dao.findAllUsers();
	}

}
